import { Injectable } from '@nestjs/common';
import { Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { Roles } from '../entities/roles.entity'; // 导入 Roles 实体

@Injectable() // 将元数据添加到类中，
export class RolesService {
  constructor(
    @InjectRepository(Roles) // 注入 Roles 实体的 Repository
    private readonly rolesRepository: Repository<Roles>,
  ) {}

  async create(roles: Partial<Roles>): Promise<Roles> {
    return this.rolesRepository.save(roles);
  }

  findAll(): Promise<Roles[]> {
    return this.rolesRepository.find();
  }
}
